package com.app.studyroom;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;

import com.app.studyroom.dialog.ICCardLoginDialog;
import com.app.studyroom.peripherals.icCardRead.CardReaderGuard;

public class LoginActivity extends BaseActivity {

    private Button btnAccountLoginEntry, btnFaceLogin, btnICLogin, btnAdminLogin;
    private ImageView Image_back;
    private LinearLayout layout_hide;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        btnAccountLoginEntry = findViewById(R.id.btnAccountLoginEntry);
        btnFaceLogin = findViewById(R.id.btnFaceLogin);
        btnICLogin = findViewById(R.id.btnICLogin);
        btnAdminLogin = findViewById(R.id.btnAdminLogin);
        Image_back = findViewById(R.id.ic_back);
        layout_hide = findViewById(R.id.layout_hide);

        btnAccountLoginEntry.setOnClickListener(v -> {
            Intent intent = new Intent(this, AccountLoginActivity.class);
            intent.putExtra("identity", "user");
            startActivity(intent);
        });

        layout_hide.setVisibility(View.GONE);
        btnFaceLogin.setOnClickListener(v -> {
            Intent intent = new Intent(this, FaceRecognitionActivity.class);
            intent.putExtra("identity", "user");
            startActivity(intent);
        });

        btnICLogin.setOnClickListener(v -> new ICCardLoginDialog(this).show());

        btnAdminLogin.setOnClickListener(v -> {
            Intent intent = new Intent(this, AccountLoginActivity.class);
            intent.putExtra("identity", "admin");
            startActivity(intent);
        });

        Image_back.setOnClickListener(v -> onBackPressed());

    }

    @Override
    protected void onPause() {
        super.onPause();
        CardReaderGuard.isReadingCard = false;
    }
}
